//
//  SHPayingTopView.swift
//  SuperCash
//
//  Created by Daiyi on 2024/1/14.
//

import UIKit

class SHPayingTopView: UIView {
//    typealias SHPayingTopAction = ((_ loanView: SHPayingTopView?) -> Void)
//    var action: SHPayingTopAction? = nil
//    
//    private let upAmountTip = "Importe después del reembolso: "
//    
//    private weak var amountLabel: UILabel?
//    private weak var dateLabel:UILabel?
//    private weak var upAmountLabel: BSLabel?
//    private weak var prdName: UILabel?
//    private weak var prdImage: UIImageView?
//    
//    override init(frame: CGRect, orientation: TGOrientation) {
//        super.init(frame: frame, orientation: orientation)
//        
//        // 内容
//        self.backgroundColor = .white
//        self.layer.cornerRadius = 14
//        self.tg_height.equal(240)
//        self.tg_width.equal(.fill)
//        self.tg_top.equal(14)
//        self.tg_leading.equal(16)
//        self.tg_trailing.equal(16)
//        self.tg_leftPadding = 20
////        self.tg_rightPadding = 20
//        
//        let tgFrame = TGFrameLayout()
//        tgFrame.tg_size(width: .fill, height: .wrap)
//        tgFrame.tg_top.equal(20)
//        
//        let topTitleLabel = DDFactory.initLabel(.zero, text: "El importe restante a devolver", font: .font12, textColor: .black.withAlphaComponent(0.6))
//        topTitleLabel.tg_top.equal(0)
//        topTitleLabel.tg_left.equal(0)
//        topTitleLabel.tg_height.equal(16)
//        topTitleLabel.tg_width.equal(.wrap)
//        topTitleLabel.tg_leading.equal(0)
//        tgFrame.addSubview(topTitleLabel)
//        
//        let amountLabel = DDFactory.initLabel(.zero, text: "$0", font: .regular(42), textColor: .black)
//        amountLabel.tg_top.equal(26)
//        amountLabel.tg_height.equal(46)
//        amountLabel.tg_width.equal(.fill)
//        tgFrame.addSubview(amountLabel)
//        self.amountLabel = amountLabel
//        
//        let linearPrd = TGLinearLayout(frame: CGRect(x: 0, y: 0, width: 98, height: 36), orientation: .horz)
//        linearPrd.tg_width.equal(98)
//        linearPrd.tg_height.equal(36)
//        linearPrd.tg_top.equal(0)
//        linearPrd.tg_trailing.equal(0)
//        linearPrd.layer.backgroundColor = UIColor.hex(hexString: "#EFEFEF").cgColor
//        
//        let prdImage: UIImageView = {
//            let imageView = UIImageView(frame: CGRect(x: 0, y: 0, width: 24, height: 24))
//            // 设置圆角半径
//            imageView.layer.cornerRadius = 12.0
//            // 将超出圆角范围的部分裁剪掉
//            imageView.clipsToBounds = true
//            return imageView
//        }()
//        prdImage.tg_left.equal(6)
//        prdImage.tg_top.equal(6)
//        prdImage.tg_right.equal(6)
//        prdImage.tg_bottom.equal(6)
//        prdImage.tg_size(24)
//        prdImage.centerY = 0
//        prdImage.centerX = 0
//        linearPrd.addSubview(prdImage)
//        self.prdImage = prdImage
//        
//        let prdName = DDFactory.initLabel(.zero, text: "--", font: .font12, textColor: .black)
//        prdName.tg_size(.wrap)
//        prdName.centerX = 0
//        prdName.centerY = 0
//        prdName.tg_top.equal(3)
//        linearPrd.addSubview(prdName)
//        self.prdName = prdName
//        
//        tgFrame.addSubview(linearPrd)
//        self.addSubview(tgFrame)
//        
//        let bottomL = DDFactory.initLabel(.zero, text: "La fecha de amortización más reciente", font: .font12, textColor: .black.withAlphaComponent(0.6))
//        bottomL.tg_top.equal(6)
//        bottomL.tg_height.equal(16)
//        bottomL.tg_width.equal(.fill)
//        self.addSubview(bottomL)
//        
//        let dateLabel = DDFactory.initLabel(.zero, text: "--", font: .font18, textColor: DDAppearance.shared.appTinColor)
//        dateLabel.tg_top.equal(2)
//        dateLabel.tg_height.equal(22)
//        dateLabel.tg_width.equal(.fill)
//        self.addSubview(dateLabel)
//        self.dateLabel = dateLabel
//        
//        let linear = TGLinearLayout(.vert)
//        linear.tg_top.equal(12)
//        linear.tg_width.equal(.fill)
//        linear.tg_height.equal(70)
//        linear.tg_right.equal(20)
//        linear.backgroundColor = .rgb(218, 228, 251)
//        linear.layer.cornerRadius = 10
//        self.addSubview(linear)
//        
//        let bst = NSMutableAttributedString(string: "\(upAmountTip)+100%")
//        bst.bs_font = UIFont.boldSystemFont(ofSize:12)
//        bst.bs_color = UIColor.black
//        bst.bs_set(color: UIColor.hex(hexString: "#000000", alpha: 0.9), range: NSRange(location: 0, length: 31))
//        bst.bs_set(color: UIColor.red, range: NSRange(location: 31, length: 5))
//        let textView = BSLabel()
//        textView.numberOfLines = 0
//        textView.attributedText = bst
//        
//        textView.tg_top.equal(0)
//        textView.tg_width.equal(.fill)
//        textView.tg_height.equal(26)
//        textView.textAlignment = .center
//        linear.addSubview(textView)
//        self.upAmountLabel = textView
//        
//        let button = DDFactory.initButton(CGRect(x: 0, y: 0, width: SHWindow.WIDTH - 72, height: 44), title: "Reembolso", titleColor: .black, bgColor: .rgb(252, 201, 82), radius: 10)
//        button.tg_size(button.size)
//        button.addTarget(self, action: #selector(goLoan), for: .touchUpInside)
//        
//        linear.addSubview(button)
//    }
//    
//    required init?(coder aDecoder: NSCoder) {
//        fatalError("init(coder:) has not been implemented")
//    }
//    convenience init(frame: CGRect = .zero, action: SHPayingTopAction?) {
//        self.init(frame: frame, orientation: .vert)
//        self.action = action
//    }
//    
//    func setModel(_ model: SHOrderModel?) {
//        if let model = model {
//            self.amountLabel?.text = "$\(model.pendingRepaymentAmount)"
////            self.upAmountLabel?.text = "\(self.upAmountTip)\(model.nextUpAmount)"
//            
//            let currDay = Utils.getYYYYMMddDate()
//            if(!model.payoutDate.isEmpty){
//                self.dateLabel?.text = model.payoutDate
//            }else{
//                self.dateLabel?.text = currDay
//            }
//            self.prdImage?.image = UIImage(named: "logo0\(model.productType)")
//            self.prdName?.text = "\(model.productName.replacingOccurrences(of: " ", with: "\n"))"
//        } else {
//            self.amountLabel?.text = "-"
//            self.upAmountLabel?.text = "-"
//            self.dateLabel?.text = "-"
//            self.prdName?.text = "-"
//        }
//    }
//    
//    @objc private func goLoan(_ sender: UIButton) {
//        self.action?(self)
//    }
}


